#-*- coding: utf-8 -*-

from Tkinter import *
from func import *

class gui(object):
    def __init__(self,event=None):
        self.event = event
        self.nick1 = u'Некто 1'
        self.nick2 = u'Некто 2'

    def view(self):
        self.root = Tk()
        self.root.geometry('+500+500')
        self.root.title = ''
        self.main()
        self.root.mainloop()

    def main(self):
        self.v=IntVar(self.root,0)
        self.text=StringVar()

        Radiobutton(self.root, text=u'Обоим', variable=self.v, value=0).grid(row=1, column=1)
        Radiobutton(self.root, text=self.nick2, variable=self.v, value=1).grid(row=1, column=2)
        Radiobutton(self.root, text=self.nick1, variable=self.v, value=2).grid(row=1, column=3)

        self.v.set(0)
        entry=Entry(self.root,font='Arial 10', textvariable=self.text)
        entry.grid(row=2, column=1, columnspan = 3, sticky='we')
        entry.bind('<Return>',self.bind)

    def bind(self, event):
        if self.event and (not self.text.get() == ''):
            run_thread(func=self.event, name='', daemon=False, args=(self.v.get(),self.text.get(),))
        self.text.set('')
